package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Item;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/17 9:10
 */
@Mapper
public interface ItemMapper {
    /**
     * 增加
     * @param record
     * @return
     */
    @Insert({
            "insert into item_nventory_warning (item_id, in_name,in_number)" +
                    " values (#{itemId,jdbcType=INTEGER}, #{inName,jdbcType=VARCHAR}," +
                    "#{inNumber,jdbcType=INTEGER})"
    })
    int insert(Item record);


    /**
     * 删除
     * @param itemId
     * @return
     */
    @Delete({
            "delete from item_nventory_warning" +
                    " where item_id = #{itemId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer itemId);

    /**
     * 查询
     * @param itemId
     * @return
     */
    @Select({
            "select" +
                    " item_id, in_name,in_number" +
                    " from item_nventory_warning" +
                    " where item_id = #{itemId,jdbcType=INTEGER}"
    })
    @Results(id = "ItemMap",value = {
            @Result(id = true,column = "item_id",property = "itemId"),
            @Result(column = "in_name",property = "inName"),
            @Result(column = "in_number",property = "inNumber")
    })
    Item selectByPrimaryKey(Integer itemId);

    /**
     * 分页查询
     * @param rows
     * @param page
     * @param condition
     * @return
     */
    @Select("select * from item_nventory_warning where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("ItemMap")
    List<Item> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    @Select("select count(*) from item_nventory_warning where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

    /**
     * 修改
     * @param record
     * @return
     */
    @Update({
            "update item_nventory_warning"+
                    " set in_name = #{inName,jdbcType=VARCHAR},"+
                    "in_number = #{inNumber,jdbcType=INTEGER}"+
                    " where item_id = #{itemId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Item record);

}
